<fieldset>
    <legend>
        Add New Item
    </legend>
    <form method="post" action="{{$base_index_url}}/{{$current_module}}/admin/{{$current_controller}}/add_item" onsubmit="$.blockUI();">
        <table width="50%">
            <tr>
                <td align="left">Part#:<input type="text" name="txt_ipnum"/> </td>
                <td align="left">Qty: <input type="text" name="txt_iqty" class="medium" /> </td>
                <td align="left"><button>Add</button></td>
            
            </tr>
        </table>
        <input type="hidden" name="order_id" value="{{$order->id}}"/>
    </form>
</fieldset>
<fieldset >
    <legend>Ordered Items</legend>
    <table width="100%" id="table">
        <tr>
            <th>
                PartNum
            </th>
            <th>
                Description
            </th>
            <th style="text-align: right">
                Quantity
            </th>
            <th style="text-align: right">
                Unit Price
            </th>
            <th style="text-align: right">
                Total Ptice
            </th>
            <th style="padding-left: 20px;text-align: center">Action</th>
        </tr>

        {{foreach from=$order->order_item_m_order->get() item=i}}
        <form name="f_{{$i->id}}" id="f_{{$i->id}}" method="post" action="{{$base_index_url}}/{{$current_module}}/admin/{{$current_controller}}/update_item">
        <tr class="table_row">
            <td>
                {{$i->part_num}}
            </td>
            <td>
                {{$i->short_desc}}
            </td>
            <td align="right">
                <input type="text" name="iqty" size="3" style="width: 30px;text-align: right" value="{{$i->qty|string_format:"%.0f"}}"  />
                
            </td>
            <td align="right">
                ${{$i->unit_price|string_format:"%.2f"}}
            </td>
            <td align="right">
                ${{$i->price_x_qty()|string_format:"%.2f"}}
            </td>
            <td style="padding-left: 20px;text-align: center">                 
                <img src="{{$core_images}}/common/save_update.png" title="Save Changes" onclick="submit_update_form('f_{{$i->id}}')" />
                    <input type="hidden" name="order_id" value="{{$order->id}}"/>
                    <input type="hidden" name="item_id" value="{{$i->id}}"/>
                &nbsp;
                <img src="{{$core_images}}/common/delete.png" title="Delete this order" onclick="delete_item('{{$i->part_num}}', {{$order->id}},{{$i->id}})" />
            </td>
        </tr>
        </form>
        {{/foreach}}
    </table>
</fieldset>
<script type="text/javascript">
    function delete_item(pnum,oid,iid){
        if(confirm("Do you really want to delete '"+pnum+"' ?" )){
            $.blockUI();
            document.location = module_admin_url+"/"+current_controller+"/remove_item/"+oid+"/"+iid;
        }
    }
    function submit_update_form(form_id){
        $.blockUI();
        document.forms[form_id].submit();
    }
</script>